<% 
    int current_page = (Integer) request.getAttribute("page");
    int total_pages = (Integer) request.getAttribute("pagesCount");
    String path = (String) request.getParameter("path");
    if (total_pages > 1) {
%>
<div class="grey_block" style="text-align: center;">
        Page:&nbsp
        <%

        if (current_page > 1) {
            out.print("<a href=\"" + request.getContextPath() + "/" + path + "?page=" + Integer.toString(current_page - 1) + "\" class=\"grey_block_left_right\">&#9668</a>&nbsp&nbsp");
        }
        for (int i=Math.max(1, current_page - 3); i <= Math.min(current_page + 3, total_pages); i++) {
            if (i == current_page) {
                out.print("<b><u>");
            }
            out.print("<a href=\"" + request.getContextPath() + "/" + path + "?page=" + Integer.toString(i) + "\">"
                    + Integer.toString(i) + "</a>");
            if (i == current_page) {
                out.print("</u></b>");
            }
            out.print("&nbsp&nbsp");
        }
        if (current_page < total_pages) {
            out.print("<a href=\"" + request.getContextPath() + "/" + path + "?page=" + Integer.toString(current_page + 1) + "\" class=\"grey_block_left_right\">&#9658</a>");
        }
        %>
</div>
<%  }   %>